home *** CD-ROM | disk | FTP | other *** search
- // ===============================================================
- // Fragment Program: Heat Source Pass
- // Description: Output heat
- // Last Update: 18/12/2003
- // Coder: Tiago Sousa
- // ===============================================================
-
- #include "../CGVPMacro.csi"
-
- MainInput
- {
- #ifdef OPENGL
- uniform samplerRECT ScreenTexMask : texunit0,
- uniform samplerRECT ScreenTex : texunit1,
- #endif
- #ifdef D3D
- uniform sampler2D ScreenTexMask : texunit0,
- uniform sampler2D ScreenTex : texunit1,
- #endif
- uniform sampler2D HeatPaleteTex : texunit2,
- uniform float4 vHeatConstants
- }
-
- DeclarationsScript
- {
- OUT_T0_T1_T2
- FOUT
- }
-
- CoreScript
- {
- // fetch textures
- #ifdef OPENGL
- float4 vMaskColor = texRECT(ScreenTexMask, IN.Tex0.xy);
- float4 vScreenColor = texRECT(ScreenTex, IN.Tex1.xy);
- #endif
- #ifdef D3D
- float4 vMaskColor = tex2D(ScreenTexMask, IN.Tex0.xy);
- float4 vScreenColor = tex2D(ScreenTex, IN.Tex1.xy);
- #endif
- float4 vHeatColor = tex2D(HeatPaleteTex, vScreenColor.ar);
-
- // heat decoding
- float4 vConstants=float4(0, 0, 0, 1);
-
- #ifdef OPENGL
- // 1st test: strong blue is used for main mask color detection
- float fColorA=saturate(dot(vMaskColor.xyz, float3(0, 0.25, 0.25)) );
-
- // 2nd test: check alpha mask
- float fColorB=4*( saturate(2*(vMaskColor.w-0.5)) );
-
- float3 fFinalMask=(fColorA<0.5)? vConstants.w: vHeatColor.xyz;
- fFinalMask=(fColorB<0.5)? fFinalMask: vConstants.w;
-
- #endif
- #ifdef D3D
- // 1st test: strong blue is used for main mask color detection
- float fColorA=saturate(dot(vMaskColor.xyz, float3(0, 0.251, 0.251)) );
-
- // 2nd test: check alpha mask
- float fColorB=4*vMaskColor.w;
-
- float3 fFinalMask=(fColorA<0.49)? vHeatColor.xyz: vConstants.w;
- fFinalMask=(fColorB<0.49)? vConstants.w: fFinalMask;
- #endif
-
- OUT.Color.xyz = fFinalMask;
- OUT.Color.w = 1;
- }